/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import bsc.ejb.metadata.Colorimetry;
import bsc.ejb.metadata.MapDrawing;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class Settings implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idSettings;

    public enum Type{SCORECARD,COMPARATOR};
    public enum Command{SUM,AVG,MAX,MIN,MODE,MEDIAN};
    public enum Temporality{LAST,X_MONTHLY,X_YEARLY};
    public enum Frecuency{MONTHLY,BIMONTHLY,QUARTERLY,SEMIANNUAL,ANNUAL};
    public enum Polarity{HIGH,LOW,SPECIAL,ZERO_TREND,ZERO_TREND_SPECIAL};
    public enum OperationData{NORMAL, CONSOLIDATESUM, CONSOLIDATEAVG, CALCULATE };

    @ManyToMany(targetEntity=Colorimetry.class)
    @JoinTable(name="ColorimetrySettings",
    joinColumns=@JoinColumn(name="idSettings"),
    inverseJoinColumns=@JoinColumn(name="idColorimetry"))
    private Collection<Colorimetry> colorimetry;
    
    @ManyToMany(targetEntity=MapDrawing.class)
    @JoinTable(name="MapDrawingSettings",
    joinColumns=@JoinColumn(name="idSettings"),
    inverseJoinColumns=@JoinColumn(name="idMapDrawing"))
    private Collection<MapDrawing> mapDrawing;
    
    @OneToOne
    private ScoreCard scoreCard;
    @OneToOne
    private Comparator comparator;

    @Enumerated
    private Type type;
    @Enumerated
    private Command command;
    @Enumerated
    private Temporality temporality;
    @Enumerated
    private Frecuency frecuency;
    @Enumerated
    private Polarity polarity;
    @Enumerated
    private OperationData operationData;
    
    private Long x;
    
    @Column(columnDefinition="text")
    private String mathOperation;//calculate score
    
    @Column(columnDefinition="text")
    private String specialOperation;//Special score

    @Column(columnDefinition="text")
    private String zeroTrendValue;//Used by specialOperation

    @Column(columnDefinition="text")
    private String dimensionalCutOperation;// calculate ComparatorDimensionalCut dynamically

    @Temporal(value = TemporalType.DATE)
    private Date registerDate;

    public String getDimensionalCutOperation() {
        return dimensionalCutOperation;
    }

    public void setDimensionalCutOperation(String dimensionalCutOperation) {
        this.dimensionalCutOperation = dimensionalCutOperation;
    }

    public Polarity getPolarity() {
        return polarity;
    }

    public void setPolarity(Polarity polarity) {
        this.polarity = polarity;
    }

    public Frecuency getFrecuency() {
        return frecuency;
    }

    public void setFrecuency(Frecuency frecuency) {
        this.frecuency = frecuency;
    }

    public Collection<MapDrawing> getMapDrawing() {
        return mapDrawing;
    }

    public void setMapDrawing(Collection<MapDrawing> mapDrawing) {
        this.mapDrawing = mapDrawing;
    }

    public Collection<Colorimetry> getColorimetry() {
        return colorimetry;
    }

    public void setColorimetry(Collection<Colorimetry> colorimetry) {
        this.colorimetry = colorimetry;
    }

    public String getSpecialOperation() {
        return specialOperation;
    }

    public void setSpecialOperation(String specialOperation) {
        this.specialOperation = specialOperation;
    }

    public String getMathOperation() {
        return mathOperation;
    }

    public void setMathOperation(String mathOperation) {
        this.mathOperation = mathOperation;
    }

    public Comparator getComparator() {
        return comparator;
    }

    public void setComparator(Comparator comparator) {
        this.comparator = comparator;
    }

    public Long getX() {
        return x;
    }

    public void setX(Long x) {
        this.x = x;
    }
    
    public Temporality getTemporality() {
        return temporality;
    }

    public void setTemporality(Temporality temporality) {
        this.temporality = temporality;
    }

    public Command getCommand() {
        return command;
    }

    public void setCommand(Command command) {
        this.command = command;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    /**
     * @return the operationData
     */
    public OperationData getOperationData() {
        return operationData;
    }

    /**
     * @param operationData the operationData to set
     */
    public void setOperationData(OperationData operationData) {
        this.operationData = operationData;
    }
    
    /**
     * @return the zeroTrendValue
     */
    public String getZeroTrendValue() {
        return zeroTrendValue;
    }

    /**
     * @param zeroTrendValue the zeroTrendValue to set
     */
    public void setZeroTrendValue(String zeroTrendValue) {
        this.zeroTrendValue = zeroTrendValue;
    }
    
    public ScoreCard getScoreCard() {
        return scoreCard;
    }

    public void setScoreCard(ScoreCard scoreCard) {
        this.scoreCard = scoreCard;
    }

    public Long getIdSettings() {
        return idSettings;
    }

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSettings != null ? idSettings.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Settings)) {
            return false;
        }
        Settings other = (Settings) object;
        if ((this.idSettings == null && other.idSettings != null) || (this.idSettings != null && !this.idSettings.equals(other.idSettings))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.Settings[id=" + idSettings + "]";
    }

}//ends of class